#ifndef _WX_HTMLTAG_H_
#define _WX_HTMLTAG_H_

#include "wx/defs.h"
#include "wx/object.h"
#include "wx/arrstr.h"

class wxColour;
class wxHtmlEntitiesParser;

struct wxHtmlCacheItem;

class wxHtmlTagsCache : public wxObject {
    DECLARE_DYNAMIC_CLASS( wxHtmlTagsCache )
  private:
    wxHtmlCacheItem *m_Cache;
    int m_CacheSize;
    int m_CachePos;
  public:
    wxHtmlTagsCache() : wxObject() {m_CacheSize = 0; m_Cache = NULL;}
    wxHtmlTagsCache( const wxString& source );
    virtual ~wxHtmlTagsCache() {free( m_Cache );}
    void QueryTag( int at, int* end1, int* end2 );

    DECLARE_NO_COPY_CLASS( wxHtmlTagsCache )
};

class wxHtmlTag : public wxObject {
    DECLARE_CLASS( wxHtmlTag )

  protected:
    wxHtmlTag( wxHtmlTag *parent,const wxString& source, int pos, int end_pos,
               wxHtmlTagsCache *cache,wxHtmlEntitiesParser *entParser );
    friend class wxHtmlParser;
  public:
    virtual ~wxHtmlTag();
    wxHtmlTag *GetParent() const {return m_Parent;}
    wxHtmlTag *GetFirstSibling() const;
    wxHtmlTag *GetLastSibling() const;
    wxHtmlTag *GetChildren() const { return m_FirstChild; }
    wxHtmlTag *GetPreviousSibling() const { return m_Prev; }
    wxHtmlTag *GetNextSibling() const {return m_Next; }
    wxHtmlTag *GetNextTag() const;
    inline wxString GetName() const {return m_Name;}
    bool HasParam( const wxString& par ) const;
    wxString GetParam( const wxString& par, bool with_commas = false ) const;
    bool GetParamAsColour( const wxString& par, wxColour *clr ) const;
    bool GetParamAsInt( const wxString& par, int *clr ) const;
    int ScanParam( const wxString& par, const wxChar *format, void *param ) const;
    wxString GetAllParams() const;
    inline bool HasEnding() const {return m_End1 >= 0;}
    inline int GetBeginPos() const {return m_Begin;}
    inline int GetEndPos1() const {return m_End1;}
    inline int GetEndPos2() const {return m_End2;}
  private:
    wxString m_Name;
    int m_Begin, m_End1, m_End2;
    wxArrayString m_ParamNames, m_ParamValues;
    wxHtmlTag *m_Next;
    wxHtmlTag *m_Prev;
    wxHtmlTag *m_FirstChild, *m_LastChild;
    wxHtmlTag *m_Parent;
    DECLARE_NO_COPY_CLASS( wxHtmlTag )
};

#endif
